package mushystuff.dtb.core.model;

import java.util.Date;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;

import org.apache.tapestry5.beaneditor.NonVisual;

@MappedSuperclass
public abstract class PersistableBean {

    @NonVisual
    private Long id;

    @NonVisual
    private Long version;

    private Date lastModified;

    public PersistableBean() {
        version = 1L;
        lastModified = new Date();
    }

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Version
    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public Date getLastModified() {
        return lastModified;
    }

    public void setLastModified(Date lastModified) {
        this.lastModified = lastModified;
    }

}
